package com.diandian.backend.jingdong.home.exchange.controller;

import com.diandian.backend.jingdong.home.exchange.req.SkuStockUpdateOneReq;
import com.diandian.backend.jingdong.home.exchange.service.BusinessStockInService;
import com.diandian.jingdong.home.boot.starter.dto.WebResponseDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 库存-现货库存API
 */
@RestController
@RequestMapping("/business/stock/in")
public class BusinessStockInController {

    @Autowired
    private BusinessStockInService skuStockManageService;

    /**
     * 同步单个商品可用库存（使用线下门店编号）
     *
     * @return
     * @throws Exception
     */
    @PostMapping("/skuStockUpdateUsableQty")
    public WebResponseDTO skuStockUpdateUsableQty(@RequestHeader(value = "appKey") String appKey,
                                                  @RequestHeader(value = "appSecret") String appSecret,
                                                  @RequestHeader(value = "token") String token,
                                                  @RequestHeader(value = "operator") String operator,
                                                  @RequestHeader(value = "belong") String belong,
                                                  @RequestBody SkuStockUpdateOneReq data) throws Exception {
        return skuStockManageService.skuStockUpdateUsableStock(appKey, appSecret, token, operator, belong, data);
    }

    /**
     * 同步单个商品现货库存（使用线下门店编号）
     *
     * @return
     * @throws Exception
     */
    @PostMapping("/skuStockUpdateInStock")
    public WebResponseDTO skuStockUpdateInStock(@RequestHeader(value = "appKey") String appKey,
                                            @RequestHeader(value = "appSecret") String appSecret,
                                            @RequestHeader(value = "token") String token,
                                            @RequestHeader(value = "operator") String operator,
                                            @RequestHeader(value = "belong") String belong,
                                            @RequestBody SkuStockUpdateOneReq data) throws Exception {
        return skuStockManageService.skuStockUpdateOne(appKey, appSecret, token, operator, belong, data);
    }
}
